package com.bwda.dsrs.filecenter.service;

import com.bwda.dsrs.filecenter.aspect.LogTypeEnum;
import com.bwda.dsrs.filecenter.domain.BusinessConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @description:
 * @author: yz
 * @create: 2019-04-28 11:15
 */
@Component
public class LogService {

    @Autowired
    private BusUserLogService busUserLogService;

    /**
     * 记录日志
     */
    public void insertLog(String type,Integer fileId,String newName,Integer fileSizeKb){

        if (type != null && !"".equals(type)) {
            if (type.equals(LogTypeEnum.UPLOAD.value())) {
                busUserLogService.insertUserLog(fileId, newName, fileSizeKb, fileId, "个人文件上传文件成功", LogTypeEnum.UPLOAD.value(), BusinessConstants.StringConstant.OK, BusinessConstants.NumberConstant.OKRESCODE, null);
            }
            if (type.equals(LogTypeEnum.GROURPUPLOAD.value())) {
                busUserLogService.insertUserLog(fileId, newName, fileSizeKb, fileId, "自定义组文件上传文件成功", LogTypeEnum.UPLOAD.value(), BusinessConstants.StringConstant.OK, BusinessConstants.NumberConstant.OKRESCODE, null);
            }
            if (type.equals(LogTypeEnum.COPY.value())) {
                busUserLogService.insertUserLog(fileId, newName, fileSizeKb, fileId, "外接文件复制文件成功", LogTypeEnum.COPY.value(), BusinessConstants.StringConstant.OK, BusinessConstants.NumberConstant.OKRESCODE, null);
            }
            if (type.equals(LogTypeEnum.MOVE.value())) {
                busUserLogService.insertUserLog(fileId, newName, fileSizeKb, fileId, "外接文件移动文件成功", LogTypeEnum.MOVE.value(), BusinessConstants.StringConstant.OK, BusinessConstants.NumberConstant.OKRESCODE, null);
            }
        }
    }

}